package com.tecklab.demo.controller;

import com.tecklab.demo.common.Result;
import com.tecklab.demo.dto.DepartmentDTO;
import com.tecklab.demo.param.DepartmentAddParam;
import com.tecklab.demo.param.DepartmentModifyParam;
import com.tecklab.demo.service.DepartmentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 示例Controller类
 * 提供基本的REST API端点
 */
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Resource
    private DepartmentService departmentService;

    @GetMapping("/getById")
    public Result<DepartmentDTO> getById(@RequestParam Integer id) {

        return Result.success(departmentService.getById(id));

    }


    @GetMapping("/get")
    public Result<DepartmentDTO> getByName(@RequestParam String name) {
        //
        return Result.success(departmentService.getByName(name));
    }


    @GetMapping("/getByHospitalId")
    public Result<List<DepartmentDTO>> getByHospitalId(@RequestParam Integer hospitalId) {

        return Result.success(departmentService.getByHospitalId(hospitalId));
    }


    @PostMapping("/create")
    public Result<Integer> create(@RequestBody DepartmentAddParam addParam) {
        return Result.success(departmentService.create(addParam));
    }

    @PostMapping("/modify")
    public Result<Integer> modify(@RequestBody DepartmentModifyParam modifyParam) {
        return Result.success(departmentService.modify(modifyParam));
    }


}
